package com.yc.testupload;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class ApiTest {
    public static void main(String[] args) {
        try {
            // Create URL object
            URL url = new URL("http://localhost:8899/api/documents?page=1&pageSize=1");
            
            // Open connection
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Accept", "application/json");
            
            // Check response code
            if (conn.getResponseCode() != 200) {
                System.err.println("Failed : HTTP error code : " + conn.getResponseCode());
                return;
            }
            
            // Read response content
            BufferedReader br = new BufferedReader(new InputStreamReader(
                (conn.getInputStream())));
            
            System.out.println("API Response:");
            String output;
            while ((output = br.readLine()) != null) {
                System.out.println(output);
            }
            
            // Close connection
            conn.disconnect();
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}